import unittest,os,time
from testcase.test_add_wb import Add
from utils.config import BASE_PATH
from common.HTMLTestRunner import HTMLTestRunner

if __name__ == '__main__':



    suite = unittest.TestSuite()
    loader = unittest.TestLoader()
    suite.addTests(loader.loadTestsFromTestCase(Add))
    # r = unittest.TestResult()
    # suite.run(result=r)
    # print(r)

    report_title = 'woniuboss3.5测试报告：'
    desc = '测试报告详情：'
    date = time.strftime('%Y%m%d')
    time = time.strftime('%Y%m%d%H%M%S')
    current_path = BASE_PATH

    path = current_path + '/report/' + date + '/' + time
    if not os.path.exists(path):
        os.makedirs(path)
    else:
        pass
    report_path = path + 'report.html'
    print(report_path)

    with open(report_path, 'wb') as report:
        runner = HTMLTestRunner(stream=report, title=report_title, description=desc)
        runner.run(suite)

